//
// Created by francklinson on 2021/11/20 AT 11:58.
// May Saint Diana bless you!
//

#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <functional>
#include <climits>
#include <string>

using namespace std;

class Solution {
public:
    int addDigits(int num) {
        while (num >= 10) {
            num = change(num);
        }
        return num;
    }

    int change(int n) {
        int ans = 0;
        while (n) {
            ans += n % 10;
            n /= 10;
        }
        return ans;
    }
};

int main() {
    Solution solution;
    cout << solution.change(38) << endl;
    return 0;
}

